<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${question.title}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <!-- 按照官方的文档引入bootstrap.min.css，bootstrap-theme.min.css，/bootstrap.min.js-->
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/css/community.css">

    <link rel="stylesheet" href="/css/editormd.preview.min.css">
    <script src="/js/jquery-3.6.0.min.js"></script>
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="/js/editormd.min.js" type="application/javascript"></script>
    <script src="/js/lib/marked.min.js"></script>
    <script src="/js/lib/prettify.min.js"></script>
    <script src="//at.alicdn.com/t/font_2622796_nmyyg5boobj.js"></script>


</head>
<body style="background-color: #eee">
<!-- 引入bootstrap的导航条组件-->
<div th:insert="~{navigation :: nav}"></div>
<div class="alert alert-danger col-lg-12 col-md-12 col-sm-12 col-xs-12"
      th:if="${error != null}">
    <div class="row">
        <div th:text="${error}" class="col-md-2 col-md-offset-5"></div>
    </div>
</div>
<!-- 实例：流式布局容器 -->
<div class="container-fluid main profile">
    <div class="row">
        <div class="col-md-8 col-md-offset-2" style="background-color: white">
            <div class="row">
                <svg class="icon_top" aria-hidden="true" th:if="${question.isTop}">
                    <use xlink:href="#icon-tuijian"></use>
                </svg>
                <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
                    <h1><span th:text="${question.title}"></span></h1>
                    <span class="text-desc"><span th:text="${question.commentCount}"></span>个回复 |
                作者：<span th:text="${question.user.name}"></span> |
                发布时间：<span th:text="'发布时间:'+${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span> |
                阅读量：<span th:text="${question.viewCount}"></span>
            </span>
                    <hr> <!-- 分割线 -->
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" >
                        <h5>描述:  <br></h5>
                    </div>
                    <!--内容-->
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="question-view">
                        <textarea style="display:none;" th:text="${question.description}"></textarea>
                    </div>
                    <script type="text/javascript">
                        $(function () {
                            editormd.markdownToHTML("question-view", {});
                        });
                    </script>
                    <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <!--标签-->
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <span class="question-tag" th:each="tag : ${question.tag.split('，')}">
                            <a th:href="@{/(page=1,tag=${tag} )}"
                               th:text="${tag}" class="community-tag"></a><!--尚未实现标签寻找帖子，仅仅做出来一个小标签-->
                        </span>
                    </div><br>
                    <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <!-- 点赞按钮 已经实现了-->
                    <a th:href="'/like/'+${question.id}+'/1'">
                        <button type="button" class="btn btn-success glyphicon glyphicon-thumbs-up" th:text="'&nbsp;'+${question.likeCount}"></button>
                    </a>
                    <!-- Single button -->
                    <div class="btn-group">
                        <button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
                                th:if="${session.user != null && session.user.id == question.creator}">
                            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                            修改 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <li><a th:href="@{'/publish/' + ${question.id}}" class="community-menu">点击修改帖子</a></li>
                        </ul>
                    </div>
                    <!-- Single button -->
                    <div class="btn-group">
                        <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
                                th:if="${session.user != null && (session.user.id == question.creator ||  session.user.isAdmin)}">
                            <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                            删除帖子 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <li><a th:href="@{'/delete/'+${id}}">确认删除帖子</a></li>
                        </ul>
                    </div>
                    <!-- 管理员置顶功能的实现 -->
                    <div class="btn-group">
                        <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
                                th:if="${session.user != null && session.user.isAdmin}">
                            <span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span>
                            置顶 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <li><a th:href="@{'/settop/'+${id}}" th:if="${ not question.isTop}">确认置顶帖子</a></li>
                            <li><a th:href="@{'/settop/'+${id}}" th:if="${question.isTop}">取消置顶帖子</a></li>
                        </ul>
                    </div>

                    <!--
                                <a th:href="@{'/publish/999'}" class="community-rewriteMenu">
                                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                    修改
                                </a>
                                <a th:href="@{'/delete'}" class="community-deleteMenu">
                                    <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                                    删除
                                </a>

                    -->
                    <hr>
                    <div class="media" th:each=" comment : ${comments}">
                        <div class="media-left">
                            <a th:href="@{'/profile/'+${comment.user.id}}">

                                <img class="media-object img-rounded"
                                     th:src="${comment.user.avatarUrl}">
                            </a>
                        </div>
                        <div class="media-body">
                            <h5 class="media-heading">
                                <a th:text="${comment.user.name}" th:href="@{'/profile/'+${comment.user.id}}"></a>
                            </h5>
                            <span th:text="${comment.content}"></span><br>
                            <div class="btn-group btn-group-sm" role="group" aria-label="...">
                                <a th:href="@{'/like/'+${comment.id}+'/2'}">
                                    <button type="button" class="btn btn-info glyphicon glyphicon-thumbs-up"
                                            th:text="${comment.likeCount}"></button>
                                </a>

                            </div>
                            <span class="text-desc" th:text="'&nbsp;|&nbsp;回复时间:'+${#dates.format(comment.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>
                        </div>
                        <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    </div>

                    <form th:action="@{'/question/'+${questionId}}" method="post">
                        <div class="form-group">
                            <label for="comment">请输入你要回复的内容</label>
                            <div class="form-group">
                            <textarea name="comment" id="comment" th:text="${comment}" class="form-control" cols="10"
                                      rows="8"></textarea>
                            </div>
                        </div>
                        <div class="container-fluid main">
                            <div class="row">
                                <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
                                    <div class="alert alert-danger col-lg-12 col-md-12 col-sm-12 col-xs-12"
                                         th:text="${error}" th:if="${error != null}"></div>

                                </div> <!-- 展示错误信息 -->
                                <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12"><button type="submit" class="btn btn-success btn-publish">
                                    回复帖子
                                </button>
                                </div>

                            </div></div>

                    </form>

                </div>
                <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <h4>发起人</h4>
                        <div class="media">
                            <div class="media-left">
                                <a th:href="@{'/profile/'+${question.user.id}}">

                                    <img class="media-object img-circle"
                                         th:src="${question.user.avatarUrl}">
                                </a>
                            </div>
                            <div class="media-body">
                                <h5 class="media-heading">
                                    <span th:text="${question.user.name}"></span>
                                </h5>
                            </div>
                        </div>
                    </div>
                    <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">

                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <h4>相关问题</h4>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>